package com.example.guet_assistant.controller;
import com.example.guet_assistant.handler.MyWebSocketHandler;
import com.example.guet_assistant.pojo.entity.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebSocketController {

    @Autowired
    private MyWebSocketHandler webSocketHandler;

    @GetMapping("/sendObject")
    public String sendObject(@RequestParam Message message) {
        // 调用 WebSocket 处理器的发送方法
        webSocketHandler.sendObjectToAll(message);

        return "对象消息已发送：" + message.getContent();
    }
}